
public class PhongMaterial extends Material {
	public Color3 diffuse;
	public Color3 specular;
	public double shininess;
	
	private static final Vector3 LIGHT_DIR =  new Vector3(1.0, 1.0, 1.0).normalize();
	private static final Color3 LIGHT_COLOR = Color3.white();
	
	public PhongMaterial(Color3 diffuse, Color3 specular, double shininess, double reflectiveness)
	{
		this.diffuse = diffuse;
		this.specular = specular;
		this.shininess = shininess;
		this.reflectiveness = reflectiveness;
	}
	
	public Color3 sample(final Ray3 ray, final Vector3 position, final Vector3 normal)
	{
		double NdotL = normal.dot(LIGHT_DIR);
		Vector3 H = (LIGHT_DIR.sub(ray.direction)).normalize();
		double NdotH = normal.dot(H);
		Color3 diffuseTerm = diffuse.mul(Math.max(NdotL, 0.0));
		Color3 specularTerm = specular.mul(Math.pow(Math.max(NdotH, 0.0), shininess));

		return LIGHT_COLOR.modulate(diffuseTerm.add(specularTerm));
		//return LIGHT_COLOR.modulate(diffuseTerm);
	}
}
